﻿<Gui:XCaseGridBase
    x:Class="XCase.Gui.AttributeContainerGrid"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Model="clr-namespace:XCase.Model;assembly=Model"
    xmlns:Gui="clr-namespace:XCase.Gui"
    SizeChanged="AttributeContainerGrid_SizeChanged">

    <ScrollViewer  Name="scrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                          ScrollViewer.VerticalScrollBarVisibility="Auto">
        <StackPanel Margin="0,0,0,10">
            <Grid Name="grid" Margin="5,0,5,0">
                <Grid.Resources>
                    <Gui:RenameAliasConverter x:Key="renameAttribute"/>
                    <HierarchicalDataTemplate x:Key="attributesTemplate" 
                                              DataType="{x:Type Model:PSMAttributeContainer}" 
                                              ItemsSource="{Binding Path=PSMAttributes}">
                        <DockPanel Focusable="False">
                            <Button  Click="attBox_MouseDoubleClick">...</Button>
                            <TextBox Name="nameBox"  
                                  Text="{Binding Path=Name, Mode=OneWay}"  
                                  Width="80"
                                  IsReadOnly="True"
                                  BorderThickness="0" Padding="1,0,0,1"/>
                            <TextBox Name="aliasBox"  
                                  Text="{Binding Path=Alias, Converter={StaticResource renameAttribute}}"  
                                  GotFocus="attBox_GotFocus"
                                  LostFocus="CheckUniqueAliasName"
                                  KeyDown="KeyPressed_Down" 
                                  KeyUp="KeyPressed_Up"
                                  Width="110"
                                  BorderThickness="0" Padding="1,0,0,1" Margin="1,0,0,1">
                                        
                            </TextBox>

                        </DockPanel>
                        <!--<HierarchicalDataTemplate.Triggers>
                            <DataTrigger Binding="{Binding Path=Alias}" Value="{x:Null}" >
                                <Setter Property="Text" Value="{Binding Path=Name, Mode=}" TargetName="aliasBox" />
                                <Setter Property="FontStyle" Value="Italic" TargetName="aliasBox" />
                            </DataTrigger>
                        </HierarchicalDataTemplate.Triggers>-->
                    </HierarchicalDataTemplate>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="Auto"  />
                    <RowDefinition Height="25"  />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60" MaxWidth="60"/>
                    <ColumnDefinition MinWidth="62" />
                </Grid.ColumnDefinitions>

                <Label Name="mainLabel" Grid.Row="0" Grid.ColumnSpan="2" Focusable="True">
                    Attributes (Name, Alias)
                </Label>

                <ListView Name="attBox" Grid.Row="1" Grid.ColumnSpan="2" 
                      Focusable="False"
                      SelectionChanged="ListView_SelectionChanged"
                      ItemTemplate ="{StaticResource attributesTemplate}"
                      ItemsSource="{Binding}" 
                      KeyUp="KeyPressed_Up"                     
                      KeyDown="KeyPressed_Down" 
                      ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                      Padding="0">
                </ListView>
                <Label Grid.Row="2" Grid.ColumnSpan="2">
                    Appearance</Label>
            </Grid>
            <Gui:AppearanceGrid x:Name="appearance"/>
        </StackPanel>

    </ScrollViewer>
</Gui:XCaseGridBase>

